
module.exports = function (playAction) {
    const random = Math.random() * 3;
    let computerAction = '';

    if (random < 1) {
        computerAction = 'rock';

    } else if (random > 2) {
        computerAction = 'scissor';

    } else {
        computerAction = 'paper'
    }

    if (playAction === computerAction) {
        console.log('平局')
        return 0;
    }
    else if (
        (playAction === 'rock' && computerAction === 'scissor') ||
        (playAction === 'paper' && computerAction === 'rock') ||
        (playAction === 'scissor' && computerAction === 'paper')) {
        console.log('恭喜 你赢了')
        return -1;
    }
    else {
        console.log('你输了')
        return 1;
    }
}
